<?php
/**
 * Created by PhpStorm.
 * User: lhl
 * Date: 2020/11/9
 * Time: 17:27
 * Features: 内网ip
 */

namespace app\adminapiv3\model;


class AssestIntranetIpModel extends BaseModel
{
    /**
     * 批量查询多个IP的IP段数据
     * @param array $ips ip整型数组
    */
    public function getIpsAndAddress(array $ips){
        $where = [];
        foreach ($ips as $ip){
            $where[] = [
                ['ip_s_int', '<=', $ip],
                ['ip_e_int', '>=', $ip],
            ];
        }

        $data = $this->alias('i')->leftJoin('host_address a','i.address_id=a.id')->field('i.ip_s_int,i.ip_e_int,i.address_id,i.type,a.address')
            ->whereOr($where)->select()
            ->toArray();
        return $data;
    }

}